// 美恰
var mp = null;
function initMeiqia(custId, infoParam) {
    //创建美洽
    mq = api.require('meiQia');
    //配置初始化美洽需要的appkey
    var param = {
        appkey: "6972cb7af22df98e44860531445a606c"
    };
    //初始化美洽
    mq.initMeiQia(param, function(ret, err) {
        
    });
    mq.addChatViewListener(function(ret){
        if(ret){
            console.error('设置美恰离线'+USER.Get('custId'));
            mq.setClientOffline();
        }
    });
    if(custId) {
        //设置自定义用户Id
        var customizedIdParam = {
            id: custId,
        };
        mq.setLoginCustomizedId(customizedIdParam);
        mq.setClientInfo(infoParam);
    }
}

function getUnreadMessageCount(callback) {
    mq.getUnreadMessageCount(function(ret) {
        // ret.count 未读数量
        console.log('美恰未读消息数量----->:'+JSON.stringify(ret));
        callback(ret.count);
    })
}

// 打开美恰
function gotoMeiqia() {
    mq.show({showAvatar:true});
    mq.setClientOnline(function(ret){
        
    });
    var titleColor = {
        color: "#5AC2FF"
    };
    mq.setTitleColor(titleColor);
}